<link href="<?php echo base_url();?>css/share/preview.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
$(document).ready(function(){
	if(get_uid() == 0){
		$("#submit_comment").attr("value","请先登录");
		$("#submit_comment").removeAttr("onclick");
		$("#submit_comment").click(function(){
			window.location.href= base_url + "tipask/?user/login.html"; 	
		});
	}
	$(".star-big-off").mouseover(function(){
		rank = $(this).attr("id")[10];
		draw_rank_star(rank);
	});
	$(".star-big-on").mouseover(function(){
		rank = Number($(this).attr("id")[10]);
		draw_rank_star(rank);
	});
	$(".star-big-off").click(function(){
		rank = $(this).attr("id")[10];
		postrank(rank);
	});
	$(".star-big-on").click(function(){
		rank = Number($(this).attr("id")[10]);
		postrank(rank);
	});
	
});
function postrank(rank){
	data = {"fid":<?php echo $fid;?>,"rank":rank};
	url = "<?php echo site_url("share/ajax/addrank");?>";
	$.post(url,data,
			function(data){
				process_rank_response(data);
			});
}
function process_rank_response(data){
	$(".score")[0].innerText = data;
	$("#star_rank_description")[0].innerText = "OK!";
	
}
function draw_rank_star(rank){
	for(i = 1;i<=5;i++){
		if(rank >= i){
			$("#star_rank_"+i).attr("class","star-big-on");
			$("#star_rank_"+i)[0].innerText = "★";
		}
		else{
			$("#star_rank_"+i).attr("class","star-big-off");
			$("#star_rank_"+i)[0].innerText = "☆";
		}
	}
	description = ["很差","较差","还行","给力","无敌"];
	$("#star_rank_description")[0].innerText = description[rank-1];
}




function share_add_comment_submit(fid){
	url = "<?php echo site_url("share/ajax/addcomment");?>";
	
	comment = $("#miniEditorTextarea").val();
	
	data = {"fid":fid,"comment":comment};

	$.post(url,data,
			function(data){
				append_comment_list(get_user_name(),comment,data);
			});

}
function append_comment_list(username,comment,data){
	comment_list = "<div class=\"comment_list\">	<div class=\"comment_info\">	<span class=\"comment_username\">" + username + "</span>	<span class=\"comment_time\">现在</span></div><div class=\"comment_content\" > "	 + comment + "<br /></div></div>";
	$(comment_list).insertBefore("#add_new_comment");
	$("#miniEditorTextarea").attr("value","");
	
}


//-->
</script>
<div class="container">

<div class="right">
	    
    <div class="sidebar1 boxborder"><h3>资料分享信息</h3>
    <div class="nav">
    <span class="score"><?php printf("%.1f",$right_rank); ?></span>分
    <?php for($i=0;$i<5;$i++) if ($i<$right_rank):?>
    <span class="star-big-on" id="star_rank_<?php echo $i+1;?>">★</span>
    <?php else:?>
    <span class="star-big-off" id="star_rank_<?php echo $i+1;?>">☆</span>
    <?php endif;?>
    <span id="star_rank_description"></span>
    
     <div>已有<span id="num_rankers"><?php echo $right_rank_times; ?></span>人评价</div>
     <div>科目：<a href="<? echo base_url()."index.php/search/share/tag/".$subject;?>"><?php echo $subject; ?></a></div>
      <div>适用年份：<a href="<? echo base_url()."index.php/search/share/tag/".$year;?>"><?php echo $year; ?></a></div>
      <div>标签：<a href="<? echo base_url()."index.php/search/share/tag/".$tag;?>"><?php echo $tag; ?></a></div>
      <div>分类：<?php 
      if($category == "paper")
      	echo "试卷";
	  else if($category == "notes")
	  	echo "笔记";
	  else if($category == "textbook")
	  	echo "教材";
	  else if($category == "answer")
	  	echo "答案";
	  else
	  	echo "其他"
      	?></div>
      <div>分享人：<a href="<? echo base_url()."tipask/?u-".$uid.".html";?>"><?php echo $author; ?></a></div>
      <div>分享时间：<?php echo $time; ?></div>
     
      <div>下载次数：<?php echo $download_times; ?></div>
      <div>描述：<?php echo $description; ?></div>
   </div>
    </div>
    <div class="sidebar2 boxborder">
	    <h3>同类热门分享：</h3>
	    <ul class="nav2">
	    <?php $limit=(15>=sizeof($other_share_comments))?sizeof($other_share_comments):15;?>
	    <?php for($i = 0 ; $i < $limit ; $i++)
	    echo "<li><a href=\"#\">".$other_share_comments[$i]['file_name']."</a></li>"; ?>
	    </ul>
    </div>
    <!-- <div class="sidebar3 box_border"><h3>同类热门分享</h3>
    	<ul class="nav3"></ul>
    </div>  -->
    
</div><!-- end of right -->




<div class="left">	
 	
   
  <div class="blank1">
  <h1><?php echo $name; ?>      <input style="margin-left:" type="button" class="button_red" onclick="window.location='<?php echo site_url()."/share/document/file_download/" . $fid ?>'" value="下载" /></h1>


  </div>
  
  <div class="content">
  
  <?php
  if(strlen($swf_path) > 0)
  {
	  echo "本预览只显示前10页内容，查看完整版本请下载。如果预览不能就直接下载吧。。。。<iframe scrolling=\"no\" style=\"border-style:none;\" frameborder=\"no\" class=\"preview_iframe\" src=\"";
	  echo base_url()."flex/show.php?swf_path=".urlencode($swf_path);
	  echo "\" ></iframe>";
  }
  else
  echo "很抱歉，此文件没有预览:)";
  ?>
  
  </div>
  
  <div class="clear"></div>
    
	
    <?php foreach ($comment as $c): ?>
    <div class="comment_list">
	    <div class="comment_info">
	    	<span class="comment_username"><?php echo $c['username']; ?></span>
	    	<span class="comment_time"><?php echo $c['comment_time']; ?></span>
	    </div>
	    <div class="comment_content" >
	    	<?php echo $c['comment_content']; ?><br />
	    </div>
	    
    </div>
    <?php endforeach; ?>

	<div class="comment_list" id="add_new_comment">
    	<textarea id="miniEditorTextarea" name="comment"></textarea>
    	<input id="submit_comment" name="submit_comment" type="submit" onclick="share_add_comment_submit(<?php echo $fid;?>);" value="&nbsp;发表评论&nbsp;" class="input-button">
    </div>
</div><!-- end of left -->
  
    
    


   <div class="clear"></div>
  </div>
